from mediator import mediator
from mediator . tests . test_assistant import make_mediator_test_keyword_args

class open_menu_fake :
    def __init__ ( self ) :
        self . _show_open_menu = False
        self . _hide_open_menu = False
        self . _on_browser_return = False
        self . _on_browser_action = False
        self . _entry_text_in_browser_reply = None
    def show_open_menu ( self ) :
        self . _show_open_menu = True
    def hide_open_menu ( self ) :
        self . _hide_open_menu = True
    def on_browser_return ( self ) :
        self . _on_browser_return = True
    def on_browser_action ( self ) :
        self . _on_browser_action = True
    def entry_text_in_browser_reply ( self , text ) :
        self . _entry_text_in_browser_reply = text

class arbitrary_module_fake :
    def on_browser_action ( self ) :
        pass
    def on_browser_return ( self ) :
        pass
    def entry_text_in_browser_reply ( self , text ) :
        pass

class mediator_open_menu_tests : 
    'mediator_open_menu'
    def __init__ ( self , test ) :
        self . _test = test
        self . _open_menu = open_menu_fake ( )
        self . _mediator = mediator ( )
        self . _mediator . register_modules ( ** make_mediator_test_keyword_args \
            ( 'open_menu' 
            , self . _open_menu
            , arbitrary_module_fake
            ) )
    def test_show_open_menu ( self ) :
        self . _mediator . show_open_menu ( )
        self . _test . assume_true ( self . _open_menu . _show_open_menu )
    def test_hide_open_menu ( self ) :
        self . _mediator . hide_open_menu ( )
        self . _test . assume_true ( self . _open_menu . _hide_open_menu )
    def test_on_browser_return ( self ) :
        self . _mediator . on_browser_return ( )
        self . _test . assume_true ( self . _open_menu . _on_browser_return )
    def test_on_browser_action ( self ) :
        self . _mediator . on_browser_action ( )
        self . _test . assume_true ( self . _open_menu . _on_browser_action )
    def test_entry_text_in_browser_reply ( self ) :
        self . _mediator . entry_text_in_browser_reply ( 'my text' )
        self . _test . assume_equal ( self . _open_menu . _entry_text_in_browser_reply , 'my text' )
